import request from "../../utils/request"

/*查询用户列表*/
export function findUserList(current, size, UserVO) {
    return request({
        url: '/user/findUserPage',
        method: "post",
        params: {
            current,
            size
        },
        data: UserVO
    })
}

/*删除头像*/
export function deleteFile(fileName) {
    return request({
        url: '/oss/deleteFile',
        method: "delete",
        data: {fileName}
    })
}

/*登录*/
export function login(username, password) {
    return request({
        url: '/login',
        method: 'post',
        data: {
            username,
            password
        }
    })
}

/*根据ID查询用户信息*/
export function getUserById(id) {
    return request({
        url: "/user/getUserById",
        method: 'get',
        params: {
            id
        }
    })
}

/*
添加用户
 */
export function addUser(user) {
    return request({
        url:'/user/addUser',
        method:'post',
        data:user
    })
}

/*删除用户*/

export  function deleteUserById(id) {
    return request({
        url:'/user/deleteUser',
        method:'delete',
        params:{
            id
        }
    })

}

/*编辑用户*/
export  function editUser(user) {
    return request({
        url:'/user/editUser',
        method:'put',
        data:user

    })
}


/*获取用户拥有和未拥有的权限*/
export function getRoleList(id) {
    return request({
        url:'/user/getRoleByUserId',
        method:"get",
        params:{id}
    })
}

/*给用户分配角色*/
export  function saveRoleByUserId(id,roleId) {
    return request({
      url:"/user/saveRoleByUserId",
        method:'put',
        params:{id},
        data:roleId
    })
}

